package org.styx.seata.tcc.account.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.styx.seata.tcc.account.domain.Account;

import java.math.BigDecimal;

/**
 * @date 2021/8/6
 * @auther uranus
 */
@Mapper
public interface AccountMapper extends BaseMapper<Account> {
    /**
     * 扣减金额
     * @param userId
     * @param money
     */
    void decrease(@Param("userId")Long userId, @Param("money")BigDecimal money);

    /**
     *
     * @param userId
     * @param residue
     * @param frozen
     */
    void updateFrozen(@Param("userId")Long userId,
                      @Param("residue")BigDecimal residue,
                      @Param("frozen")BigDecimal frozen);


    /**
     * 更新冻结使用
     *
     * @param userId 用户id
     * @param money  钱
     */
    void updateFrozenToUsed(@Param("userId")Long userId,
                            @Param("money")BigDecimal money);

    /**
     * 更新冷冻残留
     *
     * @param userId 用户id
     * @param money  钱
     */
    void updateFrozenToResidue(@Param("userId")Long userId,
                               @Param("money")BigDecimal money);

}
